using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Microsoft.DirectX.DirectDraw;

namespace TowerDefense_Dx.Core
{
    public class DxImage
    {
#region Khaibaobien
        protected string _imagePath;
        public string ImagePath
        {
            get{ return _imagePath;}
            set { _imagePath = value; }
        }
        protected Surface _image;
        public Surface XImage
        {
            get { return _image; }
            set { _image = value; }
        }
        protected Image _sourceImage;
        public Image SourceImage
        {
            get { return _sourceImage; }
            set { _sourceImage = value; }
        }
        protected Device _graphicDevice;
        public Device GraphicDevice
        {
            get { return _graphicDevice; }
            set { _graphicDevice = value; }
        }
#endregion

        public DxImage(string imagePath, Device graphicDevice)
        {
            _imagePath = imagePath;
            _graphicDevice = graphicDevice;
            CreateSurface();
        }
        public void CreateSurface()
        {
            _sourceImage = Image.FromFile(_imagePath);

            SurfaceDescription desc = new SurfaceDescription();
            desc.SurfaceCaps.OffScreenPlain = true;
            desc.Width = _sourceImage.Width;
            desc.Height = _sourceImage.Height;
            _image = new Surface(new Bitmap(_sourceImage),desc, _graphicDevice);
        }
        public virtual void DrawFast(int x, int y, Surface destSurface, DrawFastFlags flag)
        {
            destSurface.DrawFast(x, y, _image, flag);
        }
       
    }
}
